/*
 * Copyright (C) 2011 Young,Fey <fey.young@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package com.youngfey.sqlite

import org.junit.*
import static org.junit.Assert.*

import java.sql.Types
import static com.youngfey.sqlite.DataType.*

/**
 * 
 * @author Young,Fey <fey.young@gmail.com>
 */
class DataTypeTest {

    static J2D = [:]
    static {
        J2D.put(12, INTEGER)
        J2D.put('hell word', TEXT)
        J2D.put(new Date(), TEXT)
        J2D.put(12.34, REAL)
        J2D.put(23L, INTEGER)
    }
    @Test
    void testJava2DataType() {
        J2D.each { j, d ->
            def t = DataType.conv(j.getClass())
            println "$j(${j.getClass()}): $t"
            assertEquals d, t
        }
    }

    @Test
    void testGet() {
        [
            [INTEGER, 'INTEGER'],
            [DYNAMIC, ''],
            [DYNAMIC, null],
            [INTEGER, 'LONG'],
            [DYNAMIC, 'DATE'],
            [BLOB, 'BLOB'],
            [BLOB, 'BINARY']
        ].each {
            assertEquals it[0], DataType.getInstance(it[1])
        }
    }
}
